package com.xiaoxu.privatechat.schedule.admin;

import com.xiaoxu.privatechat.service.admin.DatabaseBakService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.Resource;

/**
 * @description 备份数据库定时器
 * @author xiaoxu
 * @date 2023/2/13
 */
@Configuration
@EnableScheduling
public class BackUpSchedule {

	@Resource
	private DatabaseBakService databaseBakService;
	
	private final Logger log = LoggerFactory.getLogger(BackUpSchedule.class);

	/**
	 * 每天凌晨一点0分0秒执行备份任务
	 */
	@Scheduled(cron="0 0 1 * * ?")
	public void backUpDatabase(){
		log.info("开始执行定时备份数据库任务！");
		databaseBakService.backup();
	}
}
